//
//  LZLoginBottomView.m
//  DoctorFAQs
//
//  Created by langZai on 2017/2/16.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "LZLoginBottomView.h"
#import "LZMyFastButton.h"

@interface LZLoginBottomView ()


@end

@implementation LZLoginBottomView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.userInteractionEnabled = YES;
        UILabel *numLabel = [[UILabel alloc] init];
        numLabel.text = @"+86";
        numLabel.font = FONT(16);
        numLabel.textColor = KHColorFromRGB(0x333333);
        numLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:numLabel];
        [numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20 *xsIZE);
            make.top.equalTo(self).offset(20 *ysIZE);
        }];
        
        // 手机号textField
        _phoneTextField = [[UITextField alloc] init];
        //_phoneTextField.delegate = self;
        _phoneTextField.font = NEWFONT(16);
        _phoneTextField.placeholder = @"您的手机号码";
        _phoneTextField.textColor = KHColorFromRGB(0x333333);
        _phoneTextField.textAlignment = NSTextAlignmentLeft;
        _phoneTextField.keyboardType = UIKeyboardTypeNumberPad;
        //_phoneTextView.backgroundColor = [UIColor redColor];
        [self addSubview:_phoneTextField];
        [_phoneTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.sizeOffset(CGSizeMake((SCREEN_Width - 200) * xsIZE, 30 *ysIZE));
            make.centerX.equalTo(self);
            make.centerY.equalTo(numLabel);
            
        }];
        
        // 占位文字
        //    _phonePlaceLabel = [[UILabel alloc] init];
        //    _phonePlaceLabel.text = @"您的手机号码";
        //    _phonePlaceLabel.textColor = KHColorFromRGB(0xaaaaaa);
        //    _phonePlaceLabel.font = NEWFONT(16);
        //    [_phoneTextField addSubview:_phonePlaceLabel];
        //    [_phonePlaceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.centerX.equalTo(self.view);
        //        make.centerY.equalTo(_phoneTextField);
        //    }];
        
        // 横线
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = KHColorFromRGB(0x4bb92c);
        [self addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            //        make.size.sizeOffset(CGSizeMake((SCREEN_Width - 40) *xsIZE, 1 *ysIZE));
            //        make.centerX.equalTo(self.view);
            //        make.top.equalTo(_phoneTextField.mas_bottom).offset(20 *ysIZE);
            make.left.equalTo(self).offset(20*xsIZE);
            make.right.equalTo(self).offset(-20*xsIZE);
            make.top.equalTo(self).offset(55 *ysIZE);
            make.height.offset(ysIZE);
        }];
        
        // 密码
        UILabel *pwdLabel = [[UILabel alloc] init];
        pwdLabel.text = @"密码";
        pwdLabel.font = FONT(16);
        pwdLabel.textColor = KHColorFromRGB(0x333333);
        pwdLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:pwdLabel];
        [pwdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20 * xsIZE);
            make.top.equalTo(lineView.mas_bottom).offset(35 *ysIZE);
        }];
        
        // 密码textField
        _pwdTextField = [[UITextField alloc] init];
        //_pwdTextField.delegate = self;
        _pwdTextField.keyboardType = UIKeyboardTypeURL;
        //_pwdTextView.backgroundColor = [UIColor redColor];
        _pwdTextField.font = NEWFONT(16);
        _pwdTextField.placeholder = @"填写密码";
        _pwdTextField.secureTextEntry = YES;
        _pwdTextField.textColor = KHColorFromRGB(0x333333);
        _pwdTextField.textAlignment = NSTextAlignmentLeft;
        [self addSubview:_pwdTextField];
        [_pwdTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.sizeOffset(CGSizeMake((SCREEN_Width - 200) *xsIZE, 30 *ysIZE));
            make.centerX.equalTo(self);
            make.centerY.equalTo(pwdLabel);
        }];
        
        //密码占位文字
        //    UILabel *pwdPlaceLabel = [[UILabel alloc] init];
        //    pwdPlaceLabel.text = @"填写密码";
        //    pwdPlaceLabel.textColor = KHColorFromRGB(0xaaaaaa);
        //    pwdPlaceLabel.font = NEWFONT(16);
        //    [_pwdTextField addSubview:pwdPlaceLabel];
        //    [pwdPlaceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.centerX.equalTo(self.view);
        //        make.centerY.equalTo(_pwdTextField);
        //    }];
        
        // 下面的横线
        UIView *lineViewB = [[UIView alloc] init];
        lineViewB.backgroundColor = KHColorFromRGB(0x4bb92c);
        [self addSubview:lineViewB];
        [lineViewB mas_makeConstraints:^(MASConstraintMaker *make) {
            //        make.size.sizeOffset(CGSizeMake((SCREEN_Width - 40) *xsIZE, 1 *ysIZE));
            //        make.centerX.equalTo(self.view);
            //        make.top.equalTo(_pwdTextField.mas_bottom).offset(20 *ysIZE);
            make.left.equalTo(self).offset(20*xsIZE);
            make.right.equalTo(self).offset(-20*xsIZE);
            make.height.offset(ysIZE);
            make.top.equalTo(lineView.mas_bottom).offset(70 *ysIZE);
            
        }];
        
        // 中间大的登录按钮
        _loginButton = [[UIButton alloc] init];
        [_loginButton setTitle:@"登陆" forState:UIControlStateNormal];
        [_loginButton setBackgroundColor:KHColorFromRGB(0x7bd661)];
        _loginButton.titleLabel.font = NEWFONT(18);
        _loginButton.layer.cornerRadius = 5;
        [_loginButton setTitleColor:KHColorFromRGB(0xffffff) forState:UIControlStateNormal];
        [self addSubview:_loginButton];
        [_loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
            //        make.size.sizeOffset(CGSizeMake(335 *xsIZE, 45 *ysIZE));
            //        make.centerX.equalTo(self.view);
            //        make.top.equalTo(lineViewB.mas_bottom).offset(25 *ysIZE);
            make.left.equalTo(self).offset(20*xsIZE);
            make.right.equalTo(self).offset(-20*ysIZE);
            make.top.equalTo(lineViewB.mas_bottom).offset(25 *ysIZE);
            make.height.offset(45*ysIZE);
            
        }];
//        [_loginButton addTarget:self action:@selector(loginButtonClick) forControlEvents:UIControlEventTouchUpInside];
        
        // 忘记密码
        _forgetBtn = [[UIButton alloc] init];
        [_forgetBtn setTitle:@"忘记密码?" forState:UIControlStateNormal];
        _forgetBtn.titleLabel.font = NEWFONT(15);
        _forgetBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
        [_forgetBtn setTitleColor:KHColorFromRGB(0x666666) forState:UIControlStateNormal];
        [self addSubview:_forgetBtn];
        [_forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            //        make.size.sizeOffset(CGSizeMake(80, 20));
            //        make.top.equalTo(_loginButton.mas_bottom).offset(21);
            //        make.right.equalTo(self.view.mas_right).offset(-30);
            make.top.equalTo(_loginButton.mas_bottom).offset(15 *ysIZE);
            make.right.equalTo(self).offset(-20*xsIZE);
            make.height.offset(20*ysIZE);
            make.width.offset(80*xsIZE);
        }];
//        [forgetBtn addTarget:self action:@selector(forgetBtnClick) forControlEvents:UIControlEventTouchUpInside];
        
        //横线
        UIView *lineViewC = [[UIView alloc] init];
        lineViewC.backgroundColor = KHColorFromRGB(0x999999);
        [self addSubview:lineViewC];
        [lineViewC mas_makeConstraints:^(MASConstraintMaker *make) {
            //        make.size.sizeOffset(CGSizeMake(SCREEN_Width - 35, 1));
            //        make.centerX.equalTo(self.view);
            //        make.top.equalTo(forgetBtn.mas_bottom).offset(50);
            make.left.equalTo(self).offset(15*xsIZE);
            make.right.equalTo(self).offset(-15*xsIZE);
            make.height.offset(ysIZE);
            make.top.equalTo(_forgetBtn.mas_bottom).offset(10*ysIZE);
        }];
        
        // 使用第三方登录Label
        UILabel *libLabel = [[UILabel alloc] init];
        libLabel.text = @"使用第三方登录";
        libLabel.textAlignment = NSTextAlignmentCenter;
        libLabel.font = NEWFONT(14);
        libLabel.textColor = KHColorFromRGB(0x999999);
        libLabel.backgroundColor = KHColorFromRGB(0xffffff);
        [self addSubview:libLabel];
        [libLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            //        make.size.sizeOffset(CGSizeMake(145, 13));
            make.center.equalTo(lineViewC);
            make.width.offset(145*xsIZE);
            make.height.offset(13*ysIZE);
            
        }];
        
        // 微信按钮
        //    UIButton *weChatBtn = [[UIButton alloc] init];
        //    [weChatBtn setTitle:@"微信" forState:UIControlStateNormal];
        //    weChatBtn.backgroundColor = [UIColor redColor];
        //
        //    weChatBtn.imageView.image = [UIImage imageNamed:@"login_weichat"];
        //
        //
        //    CGSize titleSize = weChatBtn.titleLabel.bounds.size;
        //    CGSize imageSize = weChatBtn.imageView.bounds.size;
        //    CGFloat interval = 1.0;
        //
        //    [weChatBtn setImageEdgeInsets:UIEdgeInsetsMake(0,0, titleSize.height + interval, -(titleSize.width + interval))];
        //    [weChatBtn setTitleEdgeInsets:UIEdgeInsetsMake(imageSize.height + interval, -(imageSize.width + interval), 0, 0)];
        //
        //
        //    [self.view addSubview:weChatBtn];
        //    [weChatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.size.sizeOffset(CGSizeMake(80, 80));
        //        make.left.equalTo(self.view).offset(20);
        //        make.bottom.equalTo(self.view.mas_bottom).offset(-20);
        //    }];
        
        // 微信按钮
//        LZFastButtonView *weChatView = [[LZFastButtonView alloc] initWithColor:KHColorFromRGB(0x8dc81b) withImage:[UIImage imageNamed:@"login_weichat"] withTitle:@"微信"];
        LZMyFastButton *weChatBtn = [[LZMyFastButton alloc] initWithImage:[UIImage imageNamed:@"login_weichat"] WithTitle:@"微信"];
        //[weChatView setBackgroundColor:[UIColor redColor]];
        
        self.weChatBtn = weChatBtn;
        [self addSubview:weChatBtn];
        [weChatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            //        make.size.sizeOffset(CGSizeMake(42, 64));
            //        make.left.equalTo(self.view).offset(70);
            //        make.bottom.equalTo(self.view.mas_bottom).offset(-35);
            make.left.equalTo(self).offset(70*xsIZE);
            make.top.equalTo(lineViewC.mas_bottom).offset(20*ysIZE);
            make.width.offset(42*xsIZE);
            make.height.offset(64*ysIZE);
        }];
        
        // QQ
//        LZFastButtonView *qqView = [[LZFastButtonView alloc] initWithColor:KHColorFromRGB(0x8dc81b) withImage:[UIImage imageNamed:@"login_QQ"] withTitle:@"QQ"];
        LZMyFastButton *qqBtn = [[LZMyFastButton alloc] initWithImage:[UIImage imageNamed:@"login_QQ"] WithTitle:@"QQ"];
        self.qqBtn = qqBtn;
        [self addSubview:qqBtn];
        [qqBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            //        make.size.sizeOffset(CGSizeMake(42, 64));
            //        make.centerX.equalTo(self.view);
            //        make.bottom.equalTo(self.view.mas_bottom).offset(-35);
            make.centerX.equalTo(self);
            make.top.equalTo(lineViewC.mas_bottom).offset(20*ysIZE);
            make.width.offset(42*xsIZE);
            make.height.offset(64*ysIZE);
        }];
        
        // 微博
//        LZFastButtonView *weiboView = [[LZFastButtonView alloc] initWithColor:KHColorFromRGB(0x8dc81b) withImage:[UIImage imageNamed:@"login_Microblog"] withTitle:@"微博"];
        LZMyFastButton *weiboBtn = [[LZMyFastButton alloc] initWithImage:[UIImage imageNamed:@"login_Microblog"] WithTitle:@"微博"];
        
        self.weiboBtn = weiboBtn;
        [self addSubview:weiboBtn];
        [weiboBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            //        make.size.sizeOffset(CGSizeMake(42, 64));
            //        make.right.equalTo(self.view).offset(-70);
            //        make.bottom.equalTo(self.view.mas_bottom).offset(-35);
            make.right.equalTo(self).offset(-70*xsIZE);
            make.top.equalTo(lineViewC.mas_bottom).offset(20*ysIZE);
            make.width.offset(42*xsIZE);
            make.height.offset(64*ysIZE);
        }];
    }
    return self;
}

@end
